package com.lzp.utils.error;

/**
 * 通用错误类，例如未知错误、参数不合法等
 */
public enum ResponseCode implements CommonError {

    SUCCESS(200, "SUCCESS"),
    ERROR(500, "服务器内部错误"),

    /*通用错误码--1000开头*/
    PARAMETER_VALIDATION_ERROR(10001, "参数不合法"),
    UNKNOWN_ERROR(10002, "未知错误！"),
    BEAN_CHECK_ERROR(10003, "bean验证错误，错误以map形式返回！"),
    INTERCEPTOR_TOKEN_ERROR(10004, "拦截器拦截到用户token出错"),

    /*用户相关错误码--2000开头*/
    USER_ALREADY_EXISTS(20001, "用户已经存在"),
    USERNAME_IS_BLANK(20002, "用户不能为空");

    private int code;
    private String message;

    ResponseCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public CommonError setErrorMsg(String errorMsg) {
        this.message = errorMsg;
        return this;
    }
}
